﻿using System.Globalization;
using System.Windows.Data;
using VideoTools.Extension;

namespace VideoTools.Converters
{
    public class ListCheckedConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
                return false;
            if(value is string str && str.Equals(parameter))
            {
                return true;
            }
            else if(value is Enum x )
            {
                string desc = x.Description();
                if(!string.IsNullOrEmpty(desc) && desc.Equals(parameter))
                {
                    return true;
                }
                return false;
            }
            return false;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
